package pers.zdb.ag.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * @Description:
 * @author: Adobe Chow
 * @date: 2018/8/8 18:51
 * @Copyright: www.winshang.com Inc. All rights reserved.
 */
public class FileX {

    public static String read(String filePath){
        return read(filePath,"UTF-8");
    }

    public static String read(String filePath,String charseName) {
        String str="";
        File file=new File(filePath);

        try {
            FileInputStream in=new FileInputStream(file);
            // size  为字串的长度 ，这里一次性读完
            int size=in.available();
            byte[] buffer=new byte[size];
            in.read(buffer);
            in.close();
            str=new String(buffer,charseName);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return null;

        }

        return str;

    }

}
